#include <bits/stdc++.h>
using namespace std;
const int MO = 80112002, maxn = 5e3+10;
typedef long long ll;
bool G[maxn][maxn];
int d[maxn], id[maxn], n, m;

int DP(int i){
    if(d[i]) return d[i];
    for (int j = 1; j <= n; ++j) {
        if(G[i][j])
            d[i] = (d[i]+DP(j))%MO;
    }
    if(!d[i]) d[i] = 1;
    return d[i]%MO;
}

int main() {
    ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int a, b; cin >> a >> b;
        G[a][b] = true;
        id[b]++;
    }

    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        if(!id[i]) ans =(ans + DP(i)) %MO;
    }
    cout << ans;
    return 0;
}